Skip to content

Rename team → organization, mirror minimally from WorkOS - #130

Merged
RhysSullivan merged 2 commits into
mainfrom
04-09-rename_team_organization_mirror_minimally_from_workos
Apr 9, 2026
Merged

Rename team → organization, mirror minimally from WorkOS#130
RhysSullivan merged 2 commits into
mainfrom
04-09-rename_team_organization_mirror_minimally_from_workos

Conversation

@RhysSullivan

Copy link
Copy Markdown
Collaborator

Reshape the data model to mirror WorkOS naming and reduce duplication:

  • users/teams/team_members/invitationsaccounts + organizations
  • team_idorganization_id everywhere (shared schema, postgres package, cloud)
  • Drop membership and invitation tables — AuthKit owns these
  • accounts is just the WorkOS user ID (FK anchor); profile data lives in WorkOS
  • organizations mirrors org id + name for fast executor creation

Swap auth resolution to proper Effect HttpApi middleware:

  • SessionAuth middleware (cookie security) provides SessionContext
    used by /auth/me, /auth/logout, /auth/organization
  • OrgAuth middleware provides AuthContext (org required) — used by all
    protected executor endpoints
  • Three-tier API split: public (login/callback), session (auth ops),
    protected (org-required executor ops)

Wire createOrganization through WorkOS SDK so first-time users can
bootstrap their org via the /setup flow.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Apr 9, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
executor-cloud 539226a Apr 09 2026, 08:06 PM

RhysSullivan commented Apr 9, 2026

Copy link
Copy Markdown
Collaborator Author

@RhysSullivan
RhysSullivan force-pushed the 04-09-rename_team_organization_mirror_minimally_from_workos branch from bea97fb to 6aad791 Compare April 9, 2026 17:06
@RhysSullivan
RhysSullivan marked this pull request as ready for review April 9, 2026 20:01

RhysSullivan commented Apr 9, 2026

Copy link
Copy Markdown
Collaborator Author

Merge activity

  • Apr 9, 8:02 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Apr 9, 8:03 PM UTC: Graphite rebased this pull request as part of a merge.
  • Apr 9, 8:05 PM UTC: @RhysSullivan merged this pull request with Graphite.

@RhysSullivan
RhysSullivan changed the base branch from 04-08-remove_lazy_user_team_provisioning_from_api_request_handler to graphite-base/130 April 9, 2026 20:02
@RhysSullivan
RhysSullivan changed the base branch from graphite-base/130 to main April 9, 2026 20:03
Reshape the data model to mirror WorkOS naming and reduce duplication:

- `users`/`teams`/`team_members`/`invitations` → `accounts` + `organizations`
- `team_id` → `organization_id` everywhere (shared schema, postgres package, cloud)
- Drop membership and invitation tables — AuthKit owns these
- `accounts` is just the WorkOS user ID (FK anchor); profile data lives in WorkOS
- `organizations` mirrors org id + name for fast executor creation

Swap auth resolution to proper Effect HttpApi middleware:

- `SessionAuth` middleware (cookie security) provides `SessionContext` —
  used by /auth/me, /auth/logout, /auth/organization
- `OrgAuth` middleware provides `AuthContext` (org required) — used by all
  protected executor endpoints
- Three-tier API split: public (login/callback), session (auth ops),
  protected (org-required executor ops)

Wire createOrganization through WorkOS SDK so first-time users can
bootstrap their org via the /setup flow.
The pg driver's CloudflareSocket silently hangs when a Client is reused across Workers request contexts, causing /api/scope and other endpoints to never respond after the first request. Switch DbService to postgres.js + drizzle-orm/postgres-js, which creates a fresh socket per Effect scope and aligns with Workers' per-request I/O model.

Also adds:
- Real integration test for DbService running inside the Workers runtime via @cloudflare/vitest-pool-workers, talking to PGlite over a TCP socket. Covers the sequential-scope and nested-scope patterns that hung under pg.
- Local dev PGlite socket server (scripts/dev-db.ts) so dev works without Docker or a Postgres install.
- Auto-create a WorkOS organization on first login.
- Split auth middleware into pure tag + live impl so the client bundle doesn't pull in the WorkOS SDK.
- APP_URL env var for OAuth callback redirect in dev.
- iron-webcrypto patch fixing require('buffer/index.js').
@RhysSullivan
RhysSullivan force-pushed the 04-09-rename_team_organization_mirror_minimally_from_workos branch from 6aad791 to 539226a Compare April 9, 2026 20:03
@RhysSullivan
RhysSullivan merged commit 67b0dd1 into main Apr 9, 2026
1 of 2 checks passed
RhysSullivan added a commit that referenced this pull request May 31, 2026
Reshape the data model to mirror WorkOS naming and reduce duplication:

- `users`/`teams`/`team_members`/`invitations` → `accounts` + `organizations`
- `team_id` → `organization_id` everywhere (shared schema, postgres package, cloud)
- Drop membership and invitation tables — AuthKit owns these
- `accounts` is just the WorkOS user ID (FK anchor); profile data lives in WorkOS
- `organizations` mirrors org id + name for fast executor creation

Swap auth resolution to proper Effect HttpApi middleware:

- `SessionAuth` middleware (cookie security) provides `SessionContext` —
  used by /auth/me, /auth/logout, /auth/organization
- `OrgAuth` middleware provides `AuthContext` (org required) — used by all
  protected executor endpoints
- Three-tier API split: public (login/callback), session (auth ops),
  protected (org-required executor ops)

Wire createOrganization through WorkOS SDK so first-time users can
bootstrap their org via the /setup flow.
@RhysSullivan
RhysSullivan deleted the 04-09-rename_team_organization_mirror_minimally_from_workos branch June 11, 2026 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant